{% extends "base.html" %}
{% block content %}
    <article>
        <h1 style="text-align:center;font-size:60px">{{ post.title }}</h1>
        {{ content }}
        <small style="text-align:left">Posted by {{ post.author.username }} on {{ post.date_posted.strftime('%Y-%m-%d') }}</small>
        <a href="{{url_for('edit_post', post_id=post.id)}}">Edit</a>
    </article>
{% endblock %}
{% block add %}
    <div class="container">
            <h2 style="text-align:center">Leave a comment</h2>
            <form action="{{url_for('comment', post_id=post.id)}}" method="POST">
                <textarea name="content" placeholder="Your comment here"></textarea>
                <button type="submit">Post</button>
            </form>
    </div>
    <div class="container">
        <div class="comments">
            <h2>Comments</h2>
            {% for comment in comments %}
                <div class="comment">
                    <p>{{ comment.content }}</p>
                    <small>Posted by {{ comment.auther.username }} on {{ comment.date_posted.strftime('%Y-%m-%d') }}</small>
                    {% if current_user.username == comment.auther.username or current_user.is_admin%}
                        <a href="{{ url_for('delete_comment', comment_id=comment.id) }}" class="button">Delete</a>
                    {% endif %}
                </div>
            {% endfor %}
        </div>
    </div>
    <script src="/static/js/highlight.js"></script>
    <script src="/static/js/javascript.js"></script>
    <link rel="stylesheet" href="/static/dark.css">
    <script>hljs.highlightAll()</script>
    <script>
        window.onload = function load(){
            document.getElementById("home").className="active";
        }
    </script>
{% endblock %}